	function removeOrder(orderno,productName)
	{
		//alert(productName);
		var answer = confirm("Are you sure you want to remove '"+productName+"' from cart?");
		
		if(answer==true)
		{
		
		$.ajax({url:"rest/data/removeorder.php",
type:'GET',
data : {orderno:orderno},
success:function(result){
//alert(order.order[i].productname);	
//alert('callback'+result);
var removemsg="'<font color='#FF0000'>"+productName+"</font>' has been removed from your cart";

getShoppingCart(removemsg);
}
		});
	}
	}
var setOrderCount = function(){
$.ajax({url:"rest/data/ordercount.php",
type:'GET',
success:function(result){
	document.getElementById('order_count').innerHTML=result.trim();
}	
});
}	
	
$(document).ready(function(){
setOrderCount();

});



function getShoppingCart(msg)
{
	/*if(msg==null)
	alert('msg is null');
	
	else
	alert('msg is : '+msg);*/

	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	xmlhttp.onreadystatechange=function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
				 count=5-5;
	//alert('count:'+count);

		setOrderCount();
		var order = xmlhttp.responseText;
		//alert(order);
		order = JSON.parse(xmlhttp.responseText);
		count = order.ordercount;
		//alert('count'+count);
		var text='';
		//var x=document.getElementById("cart_table").rows[0].cells;
	if(count>0)
	{
				var table='<table border="0"  align="center" cellpadding="5" cellspacing="2" >';
				
				if(msg!=null)
				{
				table=table+'<tr><td colspan="6">'+msg+'</td></tr>';
				}
				table=table+'<tr bgcolor="#66C"><td colspan="6"><h1  align="left">Items in your cart</h1></td></tr>';


		
				 table=table+'<tr  align="center" bgcolor="#0C3"> <td colspan="2"><h4>Product</h4></td> <td><h4>Qty.</h4></td> <td><h4>Each</h4></td> <td><h4>Subtotal</h4></td> <td bgcolor="#F60"><h3>Remove</h3></td></tr>';
				 
		var total_quantity=0;
		var total_price=0;
		for(i=0;i<count;i++)
				{
			 temp=order.order[i].productname;
					table=table
					+'<tr align="center">'
					+'<td><img  src="images/tshirts/ts'+order.order[i].productid+'.jpg" height="80" width="80"></td>'
					+'<td>'+order.order[i].productname+'</td>'
					+'<td>'+order.order[i].quantity+'</td>'
					+'<td>'+order.order[i].rate+'</td>'
					+'<td>'+order.order[i].rate*order.order[i].quantity+'</td>'
					+'<td><a href="javascript:removeOrder('+i+',\''+order.order[i].productname+'\');"  id="removefromcart"> <img  src="images/remove_cart.png" ></a></td>'
					+'</tr>';
					
					total_quantity=total_quantity*1+order.order[i].quantity*1;
					total_price+=order.order[i].rate*order.order[i].quantity;
								
				}
			
		table=table+'<tr><td colspan="6"><hr></td></tr>'
				   +'<tr align="center">'
				   +'<td colspan="2"><h3>Grand Total</h3></td>'
				   +'<td>'+total_quantity+'</td>'
				   +'<td>Rs.</td>'	
				   +'<td><h4>&nbsp; '+ total_price+' /- </h4></td>'
				   +'<td><a href = "checkout.php" class="wishbtn" >Proceed</a></td>'	
				   +'</tr>';
				   
		/*table=table+'<tr align="right">'	
				   +'<td colspan="6"><a href = "checkout.php" class="wishbtn" >Proceed</a></td>'
				   +'</tr>';
				   */
				   
				   table = table + '<tr align="center"><td colspan="6"><a href = "javascript:void(0)" onclick = "document.getElementById(\'light\').style.display=\'none\';document.getElementById(\'fade\').style.display=\'none\'"><h4>Continue shopping</h4></a></td></tr>';
		table=table+'</table>';
		
		
	}
	
	//alert('count:'+count);

		if(count>0)
				document.getElementById('table_container').innerHTML=table;
 		
		else	{
			
				
				if(msg!=null)
				{
				var remove_msg_table='<table border="0"  align="center" ><tr><td >'+msg+'</td></tr></table>';
				//alert('ater table');
				}
				
				var cart_empty_table
				
				=		'<br><br><table border="0"  align="center" cellpadding="5" cellspacing="2" width="300">';
				cart_empty_table=cart_empty_table+
				
				'<tr><td><h1  align="center">Your cart is empty</h1></td></tr>'+
		'<tr align="center"><td ><a href = "javascript:void(0)" onclick = "document.getElementById(\'light\').style.display=\'none\';document.getElementById(\'fade\').style.display=\'none\'"><h3>Start adding items</h3></a></td></tr>'+
		'</table>';
		//alert(msg);
				if(msg!=null)
				{
				document.getElementById('table_container').innerHTML=remove_msg_table+cart_empty_table;
								//alert('ater print');

				}
				else document.getElementById('table_container').innerHTML=cart_empty_table;
		
				}
				
	  }
		
		setOrderCount();
	  }
	  //alert(count);
	xmlhttp.open("GET","rest/data/shoppingcart.php",true);
	xmlhttp.send();
}